import java.io.*;

/**
 * Author: Daniel Michalski
 * Date: 27.03.13
 */

public class Main {
    private static final String FILE_NAME = "Test.dat";

    public static void main(String[] args) {
        try (DataOutputStream dout =
                new DataOutputStream(new FileOutputStream(FILE_NAME))) {
            dout.writeDouble(98.6);
            dout.writeInt(1000);
            dout.writeBoolean(true);
        } catch (FileNotFoundException ex) {
            System.out.println("Nie można oworzyć pliku wyjściowego");
            return;
        } catch (IOException ex) {
            System.out.println("Błąd wejścia-wyjścia: " + ex);
        }

        try (DataInputStream din =
                new DataInputStream(new FileInputStream(FILE_NAME))) {
            double d = din.readDouble();
            int i = din.readInt();
            boolean b = din.readBoolean();

            System.out.println("double = " + d);
            System.out.println("int = " + i);
            System.out.println("boolean = " + i);
        } catch (FileNotFoundException ex) {
            System.out.println("Nie znaleziono pliku");
        } catch (IOException ex) {
            System.out.println("Błąd I/O: " + ex);
        }
    }
}
